<?php

require_once ("include/webservice/WebServiceServer.php");
require_once ("include/auth/DyAuth.php");
$dbbase ="hh";
if ($_REQUEST['email']) {
    $result = checkSub($_REQUEST['email']);
    if ($result == 1) {
        $ip = DyAuth::getip();
        $save = saveSub($_REQUEST['email'],$ip);
    //  Header("Location: http://www.baidu.com");
    }else {
        Header("Location: http://www.google.com");
    }

}
function saveSub($email,$ip)
{
  $d =  date("Y-m-d H:i:s");
  $DB = new DB_MYSQL();
  $DB->connect();
  $sql="insert into `hh_unsubscribe`(id,email,cancel_time,cancel_ip)" ."VALUES(null,'".$email."','".$d."','".$ip."')";
 // $sql = "update `hh_user` set `last_login`= '".$now."',`last_ip`='".$ip."' WHERE `account` = '".$username."' AND `password` = '".$password."'";
  $DB->insert($sql, $dbbase);
  echo $DB->affected_rows;
}
function checkSub($email) {
    $exp = "^[a-z'0-9]+([._-][a-z'0-9]+)*@([a-z0-9]+([._-][a-z0-9]+))+$";
    if(eregi($exp,$email)) { //先用正则表达式验证email格式的有效性

        return true;


    }else {

        return false;

    }

}


//echo PRE.'hhj';



?>
